package multiThreading;

import java.util.concurrent.CyclicBarrier;

public class L {
    private static CyclicBarrier c=new CyclicBarrier(4);
    public static void main(String arg[]){
        for(int i=0;i<4;i++){//设置四个线程
            new l1(c).start();
        }

    }
}
class l1 extends Thread{
    private CyclicBarrier c;
    public l1(CyclicBarrier c){
        this.c=c;
    }

    @Override
    public void run() {
        try {
            sleep(2000);
            System.out.println("线程等待状态中");
            c.await();

        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程等待结束，开始执行！");
    }
}
